﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>方向条件-按审核组件的立场计算</title>
    <link href="../../Scripts/easyUI145/themes/default/easyui.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript" src="../../Scripts/bootstrap/js/jquery.min.js"></script>
    <script type="text/javascript" src="../../Scripts/bootstrap/js/bootstrap.min.js"></script>
    <script src="../../Scripts/QueryString.js" type="text/javascript"></script>
    <script src="../../Scripts/config.js" type="text/javascript"></script>
    <script src="../../Comm/Gener.js" type="text/javascript"></script>
    <script src="../Admin.js" type="text/javascript"></script>

    <script src="../../Scripts/easyUI/jquery-1.8.0.min.js" type="text/javascript"></script>
    <link href="../../../DataUser/Style/ccbpm.css" rel="stylesheet" type="text/css" />
    <base target="_self" />
    <style>
        #Btn_Back {
            background-image: url(../../Img/Btn/Back.png) !important;
        }

        #Btn_Save {
            background-image: url(../../Img/Btn/Save.png) !important;
        }
    </style>
    <script type="text/javascript">

        function Esc() {
            if (event.keyCode == 27)
                window.close();
            return true;
        }
        var condOrAnd = GetQueryString("CondOrAnd");
        //初始化页面函数.....
        $(function () {

            //检查当前审核组件的状态.
            var condType = GetQueryString("CondType");
            var fk_flow = GetQueryString("FK_Flow");
            var fk_mainNode = GetQueryString("FK_MainNode");
            var fk_Node = GetQueryString("FK_Node");
            var toNodeID = GetQueryString("ToNodeID");

            var en = new Entity("BP.WF.Template.FrmWorkCheck", fk_Node);
            if (en.FWCSta != 0) {
                $("#Msg1").html("<font color=red>当前审核组件是非启用状态，您不能设置此模式.</fon>");
            }

            var handler = new HttpHandler("BP.WF.HttpHandler.WF_Admin_Cond");
            handler.AddUrlData();
            handler.AddPara("FK_Node", fk_Node);
            handler.AddPara("CondType", condType);
            handler.AddPara("FK_Flow", fk_flow);
            handler.AddPara("FK_MainNode", fk_mainNode);
            handler.AddPara("ToNodeID", toNodeID);
            var data = handler.DoMethodReturnString("CondByWorkCheck_Init");

            if (data.indexOf('err@') == 0) {
                $("#Msg").html("<font color=red>加载失败:<br>" + data + "</font> .");
                return;
            }

            if (data.indexOf('url@') == 0) {
                var url = data.replace('url@', '');
                window.location.href = url;
                return;
            }

            //转json.
            data = JSON.parse(data);
            var docs = data.OperatorValue;
            //en.FWCView = "同意,不同意,酌情处理";
            if (en.FWCView == "") {
                $("#Msg2").html("<font color=red>您没有设置立场，无法设置按照立场设置转向条件</fon>");
            } else {

                //同意,不同意,酌情处理
                var strs = en.FWCView.split(',');
                var html = "";
                for (var i = 0; i < strs.length; i++) {
                    var str = strs[i]
                    html += "<option value=" + str + ">"+str+"</option>"
                }
                
                $("#DDL_Docs").append(html);
                
            }
            document.getElementById("DDL_Docs").value = docs;
            document.getElementById("TB_Note").value = data.Note;
            //设置默认选中第一个
            $("#DDL_Docs").find('option:first').prop("selected", 'selected');
        });

        //执行保存..
        function Save() {

            var condType = GetQueryString("CondType");
            var fk_flow = GetQueryString("FK_Flow");
            var fk_mainNode = GetQueryString("FK_MainNode");
            var fk_Node = GetQueryString("FK_Node");

            var toNodeID = GetQueryString("ToNodeID");
            var sqlVal = document.getElementById("DDL_Docs").value;
            var note = document.getElementById("TB_Note").value;

            if (sqlVal == "") {
                alert('请输入参数.');
                return;
            }
            if (note == "") {
                alert('请输入备注说明.');
                return;
            }
            var handler = new HttpHandler("BP.WF.HttpHandler.WF_Admin_Cond");
            handler.AddPara("FK_Flow", fk_flow);
            handler.AddPara("CondType", condType);
            handler.AddPara("FK_MainNode", fk_mainNode);
            handler.AddPara("FK_Node", fk_Node);
            handler.AddPara("ToNodeID", toNodeID);
            handler.AddPara("TB_Docs", sqlVal);
            handler.AddPara("TB_Note", note);
            handler.AddPara("CondOrAnd", GetQueryString("CondOrAnd"));
            var data = handler.DoMethodReturnString("CondByWorkCheck_Save");

            if (data.indexOf('err@') == 0) {
                $("#Msg").html("<font color=red>" + data + "</font>");
                return;
            }

            if (data.indexOf('url@') == 0) {
                var url = data.replace('url@', '');
                window.location.href = url;
                return;
            }
            Back();
        }

        //执行删除..
        function Delete() {

            if (window.confirm('您确定要删除吗？') == false)
                return;

            var condType = GetQueryString("CondType");
            var fk_flow = GetQueryString("FK_Flow");
            var fk_mainNode = GetQueryString("FK_MainNode");
            var fk_Node = GetQueryString("FK_Node");
            var toNodeID = GetQueryString("ToNodeID");

            var handler = new HttpHandler("BP.WF.HttpHandler.WF_Admin_Cond");
            handler.AddPara("FK_Flow", fk_flow);
            handler.AddPara("CondType", condType);
            handler.AddPara("FK_MainNode", fk_mainNode);
            handler.AddPara("FK_Node", fk_Node);
            handler.AddPara("ToNodeID", toNodeID);

            var data = handler.DoMethodReturnString("CondByWorkCheck_Delete");

            if (data.indexOf('err@') == 0) {
                $("#Msg").html("<font color=red>" + data + "</font>");
                return;
            }

            if (data.indexOf('url@') == 0) {
                var url = data.replace('url@', '');
                window.location.href = url;
                return;
            }

            document.getElementById("TB_Docs").value = "";
            document.getElementById("TB_Note").value = "";

            if (window.confirm('保存成功,是否返回？'))
                window.location.href = window.location.href;
            Back();
        }
        //返回.
        function Back() {
            var url = window.location.href;
            url = url.replace('CondByWorkCheck.htm', 'List.htm');
            window.location.href = url;
        }
        function ToWorkCheck() {
            //var url = "../../Comm/En.htm?EnName=BP.WF.Template.FrmWorkCheck&NodeID=" + GetQueryString("FK_Node");
            var url = "../../Comm/EnOnly.htm?EnName=BP.WF.Template.FrmWorkCheck&NodeID=" + GetQueryString("FK_Node");

            WinOpen(url);
            //window.open(url);
        }
    </script>
</head>
<body onkeypress="Esc();">
    <form id="cc">
        <div style="right:30px; position:absolute; z-index:100; ">

            <!--<input type="button" value="加载模版" onclick="LoadTemplate()" />-->
            <input id="Btn_Save" type="button" value="保存" onclick="Save()" />
            <!--<input type="button" value="删除" onclick="Delete()" />-->
            <input type="button" onclick="Back()" value="返回" id="Btn_Back" />

        </div>
        <table style="position:relative;top:10px; margin: 8px; width:100%">
            <caption>
                <img style="margin-bottom:8px;" align="middle" src='../../Img/Event.png' /> 方向条件-按审核组件的立场计算
            </caption>
            <tr>
                <td style="width: 20%;">
                    请输入成立的条件(中文标签):
                </td>
                <td>
                    <select style="width:20%" id="DDL_Docs"></select>

                    <!--<input type="text" id="TB_Docs" name="TB_Docs" style="width: 95%;" />-->
                </td>
            </tr>
            <tr>
                <td>
                    备注(不为空):
                </td>
                <td>
                    <input type="text" value="" id="TB_Note" name="TB_Note" style="width: 95%;" />
                </td>
            </tr>
        </table>

        <div style="text-align: left">
            <h4>
                &nbsp; &nbsp; &nbsp; &nbsp;帮助
            </h4>
            <ul>
                <li>立场编号不能为空.</li>
                <li><a href="javascript:ToWorkCheck();">审核组件属性</a>.</li>
                <li><div id="Msg1" /></li>
                <li><div id="Msg2" /></li>
            </ul>
        </div>
    </form>
    <center>
        <div id="Msg" />
    </center>
</body>
</html>
